﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace ConsoleApp2
{
    class Program
    {
       static List<student> s = new List<student>();
        static Hashtable ht = new Hashtable();
       
        
        static ArrayList ass = new ArrayList();
        static void Main(string[] args)
        {
             student c1 = new student(1, "张三", 21);
             student c2 = new student(2, "张1", 19);
             student c3 = new student(3, "张5", 15);
             student c4 = new student(4, "张4", 26);
            ht.Add(c1.Id,c1);
            ht.Add(c2.Id, c2);
            ht.Add(c3.Id, c3);
            ht.Add(c4.Id, c4);
            Console.WriteLine("请选择：1、添加学生信息。2、查询学生信息，3、删除学生信息  4、退出");
            int a = int.Parse(Console.ReadLine());
            switch (a)
            {
                case 1:
                    a1();
                    break;
                case 2:
                    a2(ht);
                    break;
                case 3:
                    a3();
                    break;
                case 4:
                    break;
                default:
                    break;
            }

        }
        static void a1() {
            Console.WriteLine("学号");
            int id = int.Parse(Console.ReadLine());
            Console.WriteLine("名字");
            string name = Console.ReadLine();
            Console.WriteLine("年龄");
            int age = int.Parse(Console.ReadLine());
            student s = new student(id,name,age);

        }
        static void a2(Hashtable ht) {
            Console.WriteLine("1、查询所有（按学号排序）2、按学号查询（查没有，则打印查无此学生）");
            int a = Convert.ToInt32(Console.ReadLine());
            switch (a)
            {
                case 1:
                    ass.Sort();
                    break;
                case 2:

                    Console.WriteLine("请输入学号");
                    student z = new student();
                    foreach (student item in ht.Values)
                    {
                        if (item.Id.contains(z))
                        {
                            Console.WriteLine(item);
                            Console.WriteLine();
                        }
                    }
                    
                    break;
                default:
                    break;
            }

        }
        static void a3() {
            Console.WriteLine("请输入要删除的学生相关数据");
            string a = Console.ReadLine();
            foreach (student item in ht.Values)
            {
                if (item.Id.Equals(a))
                {
                    ht.Remove(item.Id);
                    Console.WriteLine("删除成功！");

                }
                else {
                    Console.WriteLine("查无学生");
                }
            }
        }
    }
}
